<%@ page contentType="text/html;charset=UTF-8" %>
<%@ include file="/commons/taglibs.jsp" %> 
 
<html>
<head>
	<title>选择权限组</title>
	<link href="${ctx}/skins/default/css/themes.css" rel="stylesheet" type="text/css">
	<style type="text/css">
		/*复选框被选中时其所在行的样式 */
		.checked_cls {
			background-color:#FFF9E3;
		}
 
		/*复选框被取消选中时其所在行的样式 */
		.cancel_cls {
			background-color:#FFFFFF;
		}
	</style>
	
	<link rel="stylesheet" type="text/css" href="${ctx}/skins/default/css/default.css" />
	<script type="text/javascript" src='${ctx}/js/userselector.js'></script>
	<script type="text/javascript" src="${ctx}/prototypejs/CheckboxSelectUtils.js"></script>
</head>
<body>
<table id="post_box" width="95%" border="0" align="center" cellpadding="0" cellspacing="0" class="form-table">
	<caption><b>选择权限组</b></caption>
	
	
		<tr align="center"style="background:#F0EEF1">
			<td width="20" align="center">
				<input name="checkall" type="checkbox" id="checkall"
					onclick="MultiPosSelectUtils.selectAll(this.checked);" title="全选或全不选">
			</td>
			<td align="center">权限组名称</td>
			<%--<td align="center">成员</td>--%>
		</tr>
		<c:forEach items="${pglist}" var="item" varStatus="status">
		<tr align="center">
			<td>
				<input title="打勾选择" name="alid" type="checkbox" id="alid_0" value="${item.pgid }|${item.groupname }" 
					onclick="MultiPosSelectUtils.chkClick(this);"/>		
			</td>
			<td style="word-break: break-all;" align="left">${item.groupname }</td>
			<%--<td style="word-break: break-all;" align="left">[${item.selectUserIds}]</td>--%>
		</tr>
		</c:forEach>
		
		<tr>
			<td colspan="3" align="center" bgcolor="#F9f9f9">
				<input name="savebtn" type="button" class="btn-short"
					value="确 定" onclick="MultiPosSelectUtils.submitData()">
				<input name="savebtn" type="button" class="btn-short"
					value="关 闭" onclick="MultiPosSelectUtils.closeWin()">
			</td>
	</tr>
	
</table>
<script type="text/javascript"> 
	MultiPosSelectUtils = {};
	function userselector()
	{
		this.id = '';
		this.name = '';
		this.department = '';
		this.departmentid='';
		this.position = '';
		this.deptposid='';
	}
	
	function deptselector()
	{
		this.id = '';
		this.no = '';
		this.name = '';
		this.parentid='';
		this.tel ='';
		this.email='';
		this.memo='';
		this.deptpath='';
	}
	/**
	 * 提交数据，并关闭对话框
	 */
	MultiPosSelectUtils.submitData = function() {
		var d = new userselector();
		var returnArray = new Array();
		var priGrouplist  = document.getElementsByName("alid");
		var j=0;
		for(var n = 0;n < priGrouplist.length; n++) {
	  		if(priGrouplist[n].checked) {
	    		var data = priGrouplist[n].value.split("|");
        		returnArray[j] = new userselector();
				returnArray[j].id = data[0];
				returnArray[j].name = data[1];
				j++;
	  		} 
		}
		
		if (returnArray.length == 0) {
	    	alert("请先选择权限组!");
			return;
		}
		Ext.milan.pagejs.page_knowledgetypeadd.selectGroup.callback(returnArray,'<%=request.getParameter("objId")%>');
		Ext.milan.pagejs.page_knowledgetypeadd.closeDialog();
	};
 
	/**
	 * 关闭对话框
	 */
	MultiPosSelectUtils.closeWin = function() {
		Ext.milan.pagejs.page_knowledgetypeadd.closeDialog();
	};
 
	/**
	 * 设置复选框选中/不选中时其所在行的样式
	 * 
	 * @param chkObj 复选框
	 */
	MultiPosSelectUtils.chkClick = function(chkObj){
		CheckboxSelectUtils.changeTRStyleByCheckState(chkObj);
	};
 
	/**
	 * 全选/全不选复选框
	 * 
	 * @param checkedState 具有全选功能的复选框的选中状态
	 */
	MultiPosSelectUtils.selectAll = function(checkedState) {
		var checkboxItems = document.getElementsByName("alid");
		CheckboxSelectUtils.selectAll(checkedState, checkboxItems, MultiPosSelectUtils.chkClick);
	};
 
</script>
</body></html>
